--视界扩展
local shijietuozhan = fk.CreateSkill {
    name = "mcdh_shijietuozhan",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

shijietuozhan:addEffect(fk.AfterCardsMove,{
    can_trigger = function(self, event, target, player, data)
        if not player:hasSkill(self) then return false end
        for _, current in ipairs(player.room:getAlivePlayers()) do
            if current.phase == Player.Discard then
                for _, move in ipairs(data) do
                    if move.moveReason == fk.ReasonDiscard then
                        return true
                    end
                end
                break
            end
        end
        return false
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(player, self.name, nil, "#mcdh_shijietuozhan-invoke")
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        player:drawCards(1, self.name)
        if not player:isNude() then
            local tos, cid = room:askToChooseCardsAndPlayers(
                    player,
                    {
                        targets = room:getOtherPlayers(player),
                        min_card_num = 1,
                        max_card_num = 1 ,
                        prompt=  "#mcdh_shijietuozhan-choice",
                        skill_name = self.name,
                        min_num = 1,
                        max_num = 1,
                        cancelable = false
                    }
            )
            if #tos > 0 then
                room:obtainCard(tos[1], cid, false, fk.ReasonGive, player, self.name)
            end
        end
    end
})

Fk:loadTranslationTable{
    ["mcdh_shijietuozhan"] = "广见",
    [":mcdh_shijietuozhan"] = "『视界扩展』<br>当一名角色于弃牌阶段内因弃置而失去牌后，你可以摸一张牌，然后交给其他角色一张牌。",
    ["#mcdh_shijietuozhan-invoke"] = "视界扩展:你可以摸一张牌，再交给其他角色一张牌",
    ["#mcdh_shijietuozhan-choice"] = "将一张牌交给其他角色",
}

return shijietuozhan